<?php

namespace app\api\controller\paotui;

use addons\epay\library\Service;
use app\common\controller\Api;
use think\Exception;

/**
 * 接口
 */
class Block extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];


    public function notifyx()
    {
        $paytype = "wechat";
        $pay = Service::checkNotify($paytype);
        if (!$pay) {
            echo '签名错误';
            return;
        }
        $data = $pay->verify();
        try {
            $out_trade_no = $data['out_trade_no'];
            $order_no = explode("_",$out_trade_no);

            \addons\paotui\service\Post::pay_success($order_no[0],$data['transaction_id']);
        } catch (Exception $e) {

        }
        echo $pay->success();
    }

    public function test(){
        \addons\paotui\service\Post::pay_success("4236307466289158789","111");
    }

}
